<script type="text/javascript" src="<?=site_url()?>js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<?=site_url()?>js/jquery-ui-1.8.custom.min.js"></script>
<script type="text/javascript" src="<?=site_url()?>js/jquery.ui.datepicker-th.js"></script>
<script type='text/javascript' src='<?=site_url()?>js/jquery.bgiframe.min.js'></script>
<script type='text/javascript' src='<?=site_url()?>js/jquery.ajaxQueue.js'></script>
<script type='text/javascript' src='<?=site_url()?>js/jquery.autocomplete.js'></script>
<script type='text/javascript' src='<?=site_url()?>js/localdata.js'></script>
<link type="text/css" href="<?=site_url()?>js/ui/themes/start/jquery.ui.all.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="<?=site_url()?>css/jquery.autocomplete.css" />
<script type="text/javascript" src="<?=site_url()?>js/punvalidate.js"></script>
<style>
.ui-datepicker {
	width: 15em;
}
.ui-widget {
	font-size: 10pt;
}
.ui-datepicker select.ui-datepicker-month, .ui-datepicker select.ui-datepicker-year {
	width: 60px;
}
</style>
<script language="javascript">
	$().ready(function() {		
		$("#txtBirthday").datepicker({
			showOn: 'button',
			buttonImage: '<?=site_url()?>images/calbtn.gif',
			buttonImageOnly: true,
			changeMonth: true,
			changeYear: true,
			yearRange: 'c-60:c'
		});

		$("#txtProvince").autocomplete(provinces, {
			minChars: 0,
			max: 20,
			autoFill: false,
			mustMatch: false,
			matchContains: false,
			scrollHeight: 100,
			formatItem: function(data, i, total) {
				return data[0];
			}
		});	

		$("#txtArea").autocomplete(areas, {
			minChars: 0,
			max: 20,
			autoFill: false,
			mustMatch: false,
			matchContains: false,
			scrollHeight: 100,
			formatItem: function(data, i, total) {
				return data[0];
			}
		});	

		$("#txtDistinct").autocomplete(distincts, {
			minChars: 0,
			max: 20,
			autoFill: false,
			mustMatch: false,
			matchContains: false,
			scrollHeight: 100,
			formatItem: function(data, i, total) {
				return data[0];
			}
		});	

		$("#txtRoad").autocomplete(road, {
			minChars: 0,
			max: 20,
			autoFill: false,
			mustMatch: false,
			matchContains: false,
			scrollHeight: 100,
			formatItem: function(data, i, total) {
				return data[0];
			}
		});	
	});
	function checkImageExt(obj) {
		var t = obj.value;
		var txt = obj.value.substring(obj.value.lastIndexOf(".")+1).toLowerCase();
		if(!(txt == "jpg" || txt == "jpeg" || txt == "gif" || txt == "png")) {
			alert("ไฟล์รูปภาพที่แนบมาไม่ถูกต้อง " + t + "\nกรุณาเลือกไฟล์ใหม่");	
		}
	}
	function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}
	function checkImageExt(obj) {
		var t = obj.value;
		var txt = obj.value.substring(obj.value.lastIndexOf(".")+1).toLowerCase();
		if(!(txt == "jpg" || txt == "jpeg" || txt == "gif" || txt == "png")) {
			alert("ไฟล์รูปภาพที่แนบมาไม่ถูกต้อง " + t + "\nกรุณาเลือกไฟล์ใหม่");	
			u = document.getElementById('uploader');
			u.innerHTML=' <input name="txtTutorImg" id="txtTutorImg" type="file" style="width:500px;" onchange="checkImageExt(this);" /> ';
		}
	}
	function handleTitle(val) {
		if(val.value == "อื่นๆ") {
			document.getElementById("txtTitleOther").readOnly = false;
			document.getElementById("txtTitleOther").className = "";
			document.getElementById("txtTitleOther").focus();
		} else {
			document.getElementById("txtTitleOther").readOnly = true;
			document.getElementById("txtTitleOther").className = "textReadonly";
			document.getElementById("txtTitleOther").value = "";
		}
	}
	function handleNetwork(obj) {
		var txt = 'txtNetMobile' + obj.id.substring(obj.id.length - 2);
			if(obj.value == "อื่นๆ (โปรดระบุ)") {
				document.getElementById(txt).style.visibility="visible";
				document.getElementById(txt).focus();
			} else {
				document.getElementById(txt).style.visibility="hidden";
				document.getElementById(txt).value = '';
			}
		}
	function validateForm() {
		if(document.getElementById('radTitle6').checked == true && trim(document.getElementById('txtTitleOther').value).length == 0) {
			document.getElementById('txtTitleOther').focus();
			alert("กรุณาระบุคำนำหน้าชื่อ");
			return;
		} 
		 if(trim(document.getElementById('txtFirstNameTh').value).length == 0) {
			document.getElementById('txtFirstNameTh').focus();
			alert("กรุณาใส่ชื่อ (ภาษาไทย)");
			return;		
		} 
		 if(trim(document.getElementById('txtLastNameTh').value).length == 0) {
			document.getElementById('txtLastNameTh').focus();
			alert("กรุณาใส่นามสกุล (ภาษาไทย)");
			return;
		} 
		 if(trim(document.getElementById('txtNickName').value).length == 0) {
			document.getElementById('txtNickName').focus();
			alert("กรุณาใส่ชื่อเล่น");
			return;				
		} 
		 if(trim(document.getElementById('txtFirstNameEn').value).length == 0) {
			document.getElementById('txtFirstNameEn').focus();
			alert("กรุณาใส่ชื่อ (ภาษาอังกฤษ)");
			return;		
		} 
		 if(trim(document.getElementById('txtLastNameEn').value).length == 0) {
			document.getElementById('txtLastNameEn').focus();
			alert("กรุณาใส่นามสกุล (ภาษาอังกฤษ)");
			return;		
		} 
		 if(trim(document.getElementById('txtBirthday').value).length == 0) {
			document.getElementById('txtBirthday').focus();
			alert("กรุณาใส่วันเดือนปีเกิด");
			return;		
		} 
		 if(trim(document.getElementById('txtBirthday').value).length > 0 && 
				 (new Date().getFullYear() - new Date(document.getElementById('txtBirthday').value).getFullYear()) < 5) {
				alert("กรุณาใส่วันเดือนปีเกิดให้ถูกต้อง");
				return;		
		}
		if(trim(document.getElementById('txtCitizenId').value).length < 13) {
			document.getElementById('txtCitizenId').focus();
			alert("กรุณาใส่เลขที่บัตรประชาชน หรือ passport");
			return;		
		} 
		if(!(trim(document.getElementById('txtCitizenId').value).match('^[a-zA-Z0-9]{1,}'))) {
			document.getElementById('txtCitizenId').focus();
			alert("กรุณาใส่เลขที่บัตรประชาชน หรือ passport ให้ถูกต้อง");
			return;		
		} 
		if(trim(document.getElementById('txtEmail').value).length == 0) {
			document.getElementById('txtEmail').focus();
			alert("กรุณาใส่อีเมลล์");
			return;		
		} 
		 if(isValidEmailAddress(document.getElementById('txtEmail').value) == false) {
			document.getElementById('txtEmail').focus();
			alert('รูปแบบอีเมล์ไม่ถูกต้อง');
			return;
		} 
		if(trim(document.getElementById('txtTel').value).length > 0 && isTelNo(document.getElementById('txtTel').value) == false) {
			document.getElementById('txtTel').focus();
			alert("รูปแบบเบอร์โทรศัพท์ไม่ถูกต้อง");
			return;		
		}
		if(trim(document.getElementById('txtMobile01').value).length == 0) {
			document.getElementById('txtMobile01').focus();
			alert("กรุณาใส่เบอร์โทรศัพท์มือถืออย่างน้อย 1 เบอร์");
			return;
		}
		if(trim(document.getElementById('txtMobile01').value).length > 0 && isTelNo(document.getElementById('txtMobile01').value) == false) {
			document.getElementById('txtMobile01').focus();
			alert("รูปแบบเบอร์โทรศัพท์ไม่ถูกต้อง");
			return;		
		}
		if(trim(document.getElementById('txtMobile02').value).length > 0 && isTelNo(document.getElementById('txtMobile02').value) == false) {
			document.getElementById('txtMobile02').focus();
			alert("รูปแบบเบอร์โทรศัพท์ไม่ถูกต้อง");
			return;		
		} 	
		 if(trim(document.getElementById('txtArea').value).length == 0 || trim(document.getElementById('txtProvince').value).length == 0) {
			document.getElementById('txtRoomNo').focus();
			alert("กรุณาใส่ข้อมูลที่อยู่ให้ครบถ้วน");
			return;		
		} 
		document.forms["myForm"].submit();
	}
</script>
<table width="915" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffffff"> 
      <tr>
        <td width="86"><img src="<?=site_url()?>images/toparent_14.jpg" width="86"  height="1170" alt="" /></td>
        <td width="739" valign="top">
        <form name="myForm" id="myForm" enctype="multipart/form-data" method="post" action="<?=site_url()?>register_tutor/saveApplication" onsubmit="return validateForm();">
        <table width="739" border="0" cellspacing="0" cellpadding="0" >
          <tr>
            <td width="618" height="125"><img src="<?=site_url()?>images/registertutor_15.jpg" width="618" height="125" alt="" /></td>
            <td width="121" height="125"><img src="<?=site_url()?>images/registertutor_16.jpg" width="121" height="125" alt="" /></td>
          </tr>
          <tr>
            <td height="232" background="<?=site_url()?>images/registertutor_18.jpg"colspan="2"><table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr class="style2">
                <td colspan="2"><p><span class="style22">หากท่านเป็นผู้มีคุณสมบัติ ดังนี้</span><br />
                  • ชอบการทำงานที่กำหนดเวลาเองได้<br />
                  • เป็นผู้มีความรับผิดชอบต่อตนเองสูง<br />
                  • เชี่ยวชาญในเนื้อหาวิชาที่ต้องการสอน <br />
                  • มีความสามารถในการถ่ายทอด มีเทคนิคการสอนที่ดี  และมีคุณธรรม ต้องการส่งผ่านความรู้<br />
  &nbsp;                  ไปสู้น้องๆ เยาวชนรุ่นใหม่อย่างแท้จริง</p></td>
              </tr>
              <tr>
                <td class="style2"><p>อย่ารอช้าที่จะมาเป็นส่วนหนึ่งของครอบครัว<img src="<?=site_url()?>images/buttomaward_19.jpg" width="80" height="15" /><br />
                  เพื่อร่วมกันขยายโอกาสทางการศึกษาของประเทศไทยต่อไป<br />
                  <span class="style22">ติดต่อสอบถามเพิ่มเติมได้ที่ <?php if($apply_tutor['file_name']) {echo $apply_tutor['file_name']; }?></span> 
                  </p></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
            </table></td>
            </tr>
          <tr>
            <td height="235" colspan="2"><table id="Table_01" width="739" height="235" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td><img src="<?=site_url()?>images/registertutor_19_01.jpg" width="739" height="14" alt="" /></td>
              </tr>
              <tr>
                <td><img src="<?=site_url()?>images/registertutor_19_02.jpg" width="739" height="13" alt="" /></td>
              </tr>
              <tr>
                <td><img src="<?=site_url()?>images/registertutor_19_03.jpg" width="739" height="86" alt="" /></td>
              </tr>
              <tr>
                <td><table id="Table_4" width="739" height="85" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td><img src="<?=site_url()?>images/registertutor_19_04_01.jpg" width="739" height="32" alt="" /></td>
                  </tr>
                  <tr>
                    <td background="<?=site_url()?>images/registertutor_19_04_02.jpg">
                    	<table border="0" cellspacing="1" cellpadding="1" align="center" class="styleLabel">
					<col width="110px" />
					<col width="*" />

					<tr>
						<td align="right">คำนำหน้าชื่อ</td>
						<td align="left"><input name="radTitle" type="radio"  id="radTitle1" value="นาย" checked="checked" onclick="handleTitle(this);" /> นาย 
							<input type="radio" name="radTitle" id="radTitle2" value="นาง"  onclick="handleTitle(this);" /> นาง 
							<input type="radio" name="radTitle" id="radTitle3" value="นางสาว"  onclick="handleTitle(this);" /> นางสาว 
							<input type="radio" name="radTitle" id="radTitle6" value="อื่นๆ" onclick="handleTitle(this);" /> อื่นๆ 
							<input name="txtTitleOther" type="text" id="txtTitleOther" style="width: 100px" readonly="readonly" maxlength="20" class="textReadonly" />
						</td>
					</tr>
					<tr>
						<td align="right">ชื่อ</td>
						<td align="left"><input name="txtFirstNameTh" id="txtFirstNameTh"
							type="text" maxlength="45" style="width: 120px"
							value="<?php if($form_status != 'add' && (isset($first_name_th))) echo $first_name_th; ?>" />
						<span class="red">*</span> นามสกุล <input name="txtLastNameTh"
							id="txtLastNameTh" type="text" maxlength="45"
							style="width: 120px"
							value="<?php if($form_status != 'add' && (isset($last_name_th))) echo $last_name_th; ?>" />
						<span class="red">*</span> ชื่อเล่น <input name="txtNickName"
							id="txtNickName" type="text" maxlength="45" style="width: 100px"
							value="<?php if($form_status != 'add' && (isset($nick_name))) echo $nick_name; ?>" />
						<span class="red">*</span></td>
					</tr>
					<tr>
						<td align="right">First Name</td>
						<td align="left"><input name="txtFirstNameEn" id="txtFirstNameEn"
							type="text" maxlength="45"
							value="<?php if($form_status != 'add' && (isset($first_name_en))) echo $first_name_en; ?>" />
						<span class="red">*</span> Last Name <input
							name="txtLastNameEn" id="txtLastNameEn" type="text"
							maxlength="45"
							value="<?php if($form_status != 'add' && (isset($last_name_en))) echo $last_name_en; ?>" />
						<span class="red">*</span></td>
					</tr>
					<tr>
						<td align="right">วัน เดือน ปี เกิด</td>
						<td align="left"><input name="txtBirthday" type="text"
							class="textReadonly" id="txtBirthday" size="9"
							readonly="readonly"
							value="<?php if($form_status != 'add' && (isset($birthday))) echo $birthday; ?>" />
						<span class="red">*</span>&nbsp;&nbsp;
						เลขที่บัตรประชาชน <input name="txtCitizenId" id="txtCitizenId" type="text" maxlength="30" /><span class="red">*</span>
						</td>
					</tr>
					<tr>
						<td align="right">แนบไฟล์รูปถ่าย</td>
						<td align="left">
							<input name="txtTutorImg" id="txtTutorImg" type="file" onchange="checkImageExt(this);" />
						</td>
					</tr>
					<tr style="height: 10px;">
						<td align="right"></td>
						<td align="left"></td>
					</tr>
				</table>
                    </td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td><img src="<?=site_url()?>images/registertutor_19_05.jpg" width="739" height="37" alt="" /></td>
              </tr>
            </table></td>
            </tr>
            
          <tr>
            <td height="311" colspan="2"><table id="Table_" width="739" height="311" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td><img src="<?=site_url()?>images/registertutor_20_01.jpg" width="739" height="72" alt="" /></td>
              </tr>
              <tr>
                <td><table id="Table_5" width="739" height="199" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td><img src="<?=site_url()?>images/registertutor_20_02_01.jpg" width="739" height="40" alt="" /></td>
                  </tr>
                  <tr>
                    <td background="<?=site_url()?>images/registertutor_20_02_02.jpg">
                    	<table border="0" cellspacing="1" cellpadding="1"
					class="styleLabel">
					<col width="140px" />
					<col width="*" />
					<tr>
						<td align="right"><label>E-mail</label></td>
						<td align="left"><input name="txtEmail" type="text" id="txtEmail"
							maxlength="45" value="<?php if(isset($email)) echo $email; ?>" />
						<span class="red">*</span> โทรศัพท์บ้าน <input name="txtTel"
							type="text" id="txtTel" maxlength="20"
							value="<?php if(isset($telephone_home)) echo $telephone_home; ?>" /></td>
					</tr>
					<tr>
						<td align="right" style="vertical-align: top;"><label>โทรศัพท์มือถือ</label></td>
						<td align="left">1. <input name="txtMobile01" type="text"
							id="txtMobile01" maxlength="20"
							value="<?php if(isset($mobile01)) echo $mobile01; ?>" /> <span
							class="red">*</span> เครือข่าย <select name="selNetMobile01"
							id="selNetMobile01" onchange="handleNetwork(this);">
							<option value="AIS"
							<?php if(isset($mobile01_network) == false || $mobile01_network == 'AIS') echo 'selected="selected"';?>>AIS</option>
							<option value="DTAC"
							<?php if(isset($mobile01_network)  && $mobile01_network == 'DTAC') echo 'selected="selected"';?>>DTAC</option>
							<option value="True Move"
							<?php if(isset($mobile01_network)  && $mobile01_network == 'True Move') echo 'selected="selected"';?>>True
							Move</option>
							<option value="Hutch"
							<?php if(isset($mobile01_network)  && $mobile01_network == 'Hutch') echo 'selected="selected"';?>>Hutch</option>
							<option value="ไม่ทราบ"
							<?php if(isset($mobile01_network)  && $mobile01_network == 'ไม่ทราบ') echo 'selected="selected"';?>>ไม่ทราบ</option>
							<option value="อื่นๆ (โปรดระบุ)"
							<?php if(isset($mobile01_network) && $mobile01_network != 'AIS' && $mobile01_network != 'DTAC' && $mobile01_network != 'True Move'  && $mobile01_network != 'Hutch' && $mobile01_network != 'ไม่ทราบ') echo 'selected="selected"';?>>อื่นๆ
							(โปรดระบุ)</option>
						</select> <input name="txtNetMobile01" type="text"
							id="txtNetMobile01"
							<?php if(!(isset($mobile01_network) && $mobile01_network != 'AIS' && $mobile01_network != 'DTAC' && $mobile01_network != 'True Move'  && $mobile01_network != 'Hutch' && $mobile01_network != 'ไม่ทราบ')) echo ' style="visibility:hidden;" ';?>
							maxlength="10"
							value="<?php if(isset($mobile01_network)) echo $mobile01_network; ?>" />
						<br />
						2. <input name="txtMobile02" type="text" id="txtMobile02"
							value="<?php if(isset($mobile02)) echo $mobile02; ?>" />
						&nbsp;&nbsp;&nbsp;เครือข่าย <select name="selNetMobile02" id="selNetMobile02"
							onchange="handleNetwork(this);">
							<option value="AIS"
							<?php if(isset($mobile02_network) == false || $mobile02_network == 'AIS') echo 'selected="selected"';?>>AIS</option>
							<option value="DTAC"
							<?php if(isset($mobile02_network)  && $mobile02_network == 'DTAC') echo 'selected="selected"';?>>DTAC</option>
							<option value="True Move"
							<?php if(isset($mobile02_network)  && $mobile02_network == 'True Move') echo 'selected="selected"';?>>True
							Move</option>
							<option value="Hutch"
							<?php if(isset($mobile02_network)  && $mobile02_network == 'Hutch') echo 'selected="selected"';?>>Hutch</option>
							<option value="ไม่ทราบ"
							<?php if(isset($mobile02_network)  && $mobile02_network == 'ไม่ทราบ') echo 'selected="selected"';?>>ไม่ทราบ</option>
							<option value="อื่นๆ (โปรดระบุ)"
							<?php if(isset($mobile02_network) && $mobile02_network != 'AIS' && $mobile02_network != 'DTAC' && $mobile02_network != 'True Move'  && $mobile02_network != 'Hutch' && $mobile02_network != 'ไม่ทราบ') echo 'selected="selected"';?>>อื่นๆ
							(โปรดระบุ)</option>
						</select> <input name="txtNetMobile02" type="text"
							id="txtNetMobile02"
							<?php if(!(isset($mobile02_network) && $mobile02_network != 'AIS' && $mobile02_network != 'DTAC' && $mobile02_network != 'True Move'  && $mobile02_network != 'Hutch' && $mobile02_network != 'ไม่ทราบ')) echo 'style="visibility:hidden;"';?>
							maxlength="10"
							value="<?php if(isset($mobile02_network)) echo $mobile02_network; ?>" />
						<br />
						</td>
					</tr>
					<tr>
						<td align="right" style="vertical-align: top"><label>ที่อยู่ปัจจุบัน<span
							class="red">*</span></label></td>
						<td align="left">เลขที่่ห้องพัก <input name="txtRoomNo"
							type="text" id="txtRoomNo" size="5" maxlength="10"
							value="<?php if(isset($add_room_no)) echo $add_room_no; ?>" />
						บ้านเลขที่ <input name="txtHomeNo" type="text" id="txtHomeNo"
							size="5" maxlength="10"
							value="<?php if(isset($add_home_no)) echo $add_home_no; ?>" />
						ชื่ออาคาร/คอนโดมิเนียม <input name="txtBuilding" type="text"
							id="txtBuilding" maxlength="45" style="width: 120px"
							value="<?php if(isset($add_building_name)) echo $add_building_name; ?>" />
						<br />
						หมู่ที่ <input name="txtMoo" type="text" id="txtMoo" size="5"
							maxlength="10"
							value="<?php if(isset($add_moo)) echo $add_moo; ?>" /> ซอย <input
							name="txtSoi" type="text" id="txtSoi" maxlength="45"
							value="<?php if(isset($add_soi)) echo $add_soi; ?>" /> ถนน <input
							name="txtRoad" type="text" id="txtRoad" maxlength="45"
							value="<?php if(isset($add_road)) echo $add_road; ?>" /> <br />
						แขวง <input name="txtDistinct" type="text" id="txtDistinct"
							maxlength="45"
							value="<?php if(isset($add_district)) echo $add_district; ?>" />
						เขต <input name="txtArea" type="text" id="txtArea" maxlength="45"
							value="<?php if(isset($add_area)) echo $add_area; ?>" /> จังหวัด
						<input name="txtProvince" type="text" id="txtProvince"
							style="width: 100px" maxlength="45"
							value="<?php if(isset($add_province)) echo $add_province; ?>" /><br/>
						รหัสไปรษณีย์ <input name="txtPostCode" type="text"
							id="txtPostCode" size="15" maxlength="6"
							value="<?php if(isset($add_post_code)) echo $add_post_code; ?>" />
						</td>
					</tr>
					<tr style="height: 10px;">
						<td align="right"></td>
						<td align="left"></td>
					</tr>
				</table>
                    </td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td><img src="<?=site_url()?>images/registertutor_20_03.jpg" width="739" height="40" alt="" /></td>
              </tr>
            </table></td>
            </tr>
            <tr>
      			<td align="right" style="padding-right:50px;">
      				<a href="javascript:validateForm();" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image21','','<?=site_url()?>images/registerstudy_increaseroll_24.jpg',1)"><img src="<?=site_url()?>images/registerstudy_increase_24.jpg" name="Image21" width="89" height="55" border="0" id="Image21" /></a>
      			</td>
      		</tr>
          </table></form></td>
        <td width="90"><img src="<?=site_url()?>images/toparent_18.jpg" width="90" height="1170" alt="" /></td>
      </tr>
    </table>
